<%--
  Created by IntelliJ IDEA.
  User: landeqing
  Date: 2018/1/24
  Time: 22:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="/jquery/jquery-3.2.1.min.js"></script>
<html>
<head>
    <title>添加收货地址</title>
    <script type="text/javascript">
        function cityList () {
            var p_id=$("#top").val();
            $("#center option").remove();
            $.ajax({
                url:"/order/city?pid="+p_id,
                type:"get",
                cache:false,
                success: function (res) {
                    var city=eval(res);
                    for(var i=0;i<city.length;i++){
                        var option=document.createElement("option");
                        $(option).val(city[i].id);
                        $(option).text(city[i].c_name);
                        $('#center').append(option);

                    }
                    xianList();
                }

            });
        }
        //县的ajax
        function xianList() {
            var c_id = $("#center").val();
            $("#button option").remove();
            $.ajax({
                url: "/order/county?cid=" + c_id,
                type: "get",
                cache: false,
                success: function (res) {
                    var county = eval(res);
                    for (var i = 0; i < county.length; i++) {
                        var option = document.createElement("option");
                        $(option).val(county[i].id);
                        $(option).text(county[i].x_name);
                        $('#button').append(option);
                    }
                }
            });
        }
        $(function () {
            cityList();
        });
    </script>
</head>
<body>
<form action="/order/saveOrderAddress" method="post">
    <input type="hidden" value="${sessionScope.user.id}" name="uid">
    <div style="margin-bottom:20px;">
        <label for="receiver">收货人</label>
        <input type="text" name="receiver" id="receiver" placeholder="您的昵称可以由小写英文字母、中文、数字组成" class="register_input" onkeydown="keydowTip()"/>
        <div  id="nickTip" style="display:none;color: red">昵称不能为空，请重新输入！</div>
    </div>
    <div style="margin-bottom:35px;">
        <label for="phone">手机号码</label>
        <input type="text" name="phone" id="phone" placeholder="请填写有效的手机号码"  onkeydown="keydowTip()"/>
        <div class="register_warning" id="phoneTip" style="display: none;color: red">手机号码错误，请重新输入11位手机号码！</div>
    </div>
    <tr>
        收货人地址：<td><select name="district" id="top"  onchange="cityList()">
        <c:forEach items="${provinceList}" var="obj">
            <option value="${obj.id}">${obj.p_name}</option>
        </c:forEach>
    </select></td>&nbsp;&nbsp;
        <td><select name="district" id="center" onchange="xianList()">
            <option value="" selected="selected">请选择市</option>
        </select></td>&nbsp;&nbsp;
        <td><select name="district" id="button">
            <option value="" selected="selected">请选择区/县</option>
        </select></td>&nbsp;&nbsp;
        <input type="text" name="address">
    </tr><br>
    <input type="submit" value="保存"/>
</form>
</body>
</html>
